<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<title>Other operators - cppreference.com</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/language/operator_other","wgTitle":"cpp/language/operator other","wgCurRevisionId":141217,"wgArticleId":708,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Todo with reason"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"cpp/language/operator_other","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-ColiruCompiler":1,"gadget-MathJax":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:9f05c6caceb9bb1a482b6cebd4c5a330 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_language_operator_other skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading">Other operators</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">From cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../language.html" title="cpp/language">language</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../compiler_support.html" title="cpp/compiler support"> Compiler support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../freestanding.html" title="cpp/freestanding"> Freestanding and hosted</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="cpp/language"> Language</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header"> Standard library headers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../named_req.html" title="cpp/named req"> Named requirements </a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../feature_test.html" title="cpp/feature test"> Feature test macros </a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html#Language_support" title="cpp/utility"> Language support library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concepts.html" title="cpp/concepts"> Concepts library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../meta.html" title="cpp/meta"> Metaprogramming library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error"> Diagnostics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility"> General utilities library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string"> Strings library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../container.html" title="cpp/container"> Containers library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator"> Iterators library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../ranges.html" title="cpp/ranges"> Ranges library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm"> Algorithms library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric"> Numerics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale"> Localizations library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io"> Input/output library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../filesystem.html" title="cpp/filesystem"> Filesystem library</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex"> Regular expressions library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread"> Concurrency support library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="cpp/experimental"> Technical specifications</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../symbol_index.html" title="cpp/symbol index"> Symbols index</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../links/libs.html" title="cpp/links/libs"> External libraries</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../language.html" title="cpp/language"> C++ language</a><div class="t-navbar-menu"><div><div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> General topics</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../preprocessor.html" title="cpp/preprocessor"> Preprocessor</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../comments.html" title="cpp/comment"> Comments</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../keywords.html" title="cpp/keyword"> Keywords</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="escape.html" title="cpp/language/escape"> Escape sequences</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="statements.html" title="cpp/language/statements"> Flow control</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Conditional execution statements</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="if.html" title="cpp/language/if"><tt>if</tt></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="switch.html" title="cpp/language/switch"><tt>switch</tt></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Iteration statements (loops)</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="for.html" title="cpp/language/for"><tt>for</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="range-for.html" title="cpp/language/range-for"> range-<code>for</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="while.html" title="cpp/language/while"><tt>while</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="do.html" title="cpp/language/do"> <code>do-while</code></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Jump statements </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="continue.html" title="cpp/language/continue"><tt>continue</tt></a> - <a href="break.html" title="cpp/language/break"><tt>break</tt></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="goto.html" title="cpp/language/goto"><tt>goto</tt></a> - <a href="return.html" title="cpp/language/return"><tt>return</tt></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="functions.html" title="cpp/language/functions"> Functions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="function.html" title="cpp/language/function"> Function declaration</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="lambda.html" title="cpp/language/lambda"> Lambda function expression</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="inline.html" title="cpp/language/inline"> <code>inline</code> specifier</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="except_spec.html" title="cpp/language/except spec"> Dynamic exception specifications</a> <span class="t-mark-rev t-until-cxx20">(until C++20)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="noexcept_spec.html" title="cpp/language/noexcept spec"> <code>noexcept</code> specifier</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Exceptions</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="throw.html" title="cpp/language/throw"> <code>throw</code>-expression</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="try_catch.html" title="cpp/language/try catch"> <code>try</code>-<code>catch</code> block</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Namespaces</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="namespace.html" title="cpp/language/namespace"> Namespace declaration</a>  </td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="namespace_alias.html" title="cpp/language/namespace alias"> Namespace aliases</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Types</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="types.html" title="cpp/language/types"> Fundamental types</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="enum_class.html" title="cpp/language/enum"> Enumeration types</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="function.html" title="cpp/language/function"> Function types</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="class.html" title="cpp/language/class"> Class/struct types</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="union.html" title="cpp/language/union"> Union types</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Specifiers</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="decltype.html" title="cpp/language/decltype"><tt>decltype</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="auto.html" title="cpp/language/auto"><tt>auto</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="alignas.html" title="cpp/language/alignas"><tt>alignas</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="cv.html" title="cpp/language/cv"> <code>const</code>/<code>volatile</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="constexpr.html" title="cpp/language/constexpr"><tt>constexpr</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="storage_duration.html" title="cpp/language/storage duration"> Storage duration specifiers</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="initialization.html" title="cpp/language/initialization"> Initialization</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="default_initialization.html" title="cpp/language/default initialization"> Default initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="value_initialization.html" title="cpp/language/value initialization"> Value initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="zero_initialization.html" title="cpp/language/zero initialization"> Zero initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="copy_initialization.html" title="cpp/language/copy initialization"> Copy initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="direct_initialization.html" title="cpp/language/direct initialization"> Direct initialization</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="aggregate_initialization.html" title="cpp/language/aggregate initialization"> Aggregate initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="list_initialization.html" title="cpp/language/list initialization"> List initialization</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="constant_initialization.html" title="cpp/language/constant initialization"> Constant initialization</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="reference_initialization.html" title="cpp/language/reference initialization"> Reference initialization</a></td></tr>
</table></div></td></tr>
</table></div>
</div>
<div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> <a href="expressions.html" title="cpp/language/expressions"> Expressions</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="value_category.html" title="cpp/language/value category"> Value categories</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="eval_order.html" title="cpp/language/eval order"> Order of evaluation</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="operators.html" title="cpp/language/operators"> Operators</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_precedence.html" title="cpp/language/operator precedence"> Operator precedence</a></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_alternative.html" title="cpp/language/operator alternative"> Alternative representations</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="expressions.html#Literals" title="cpp/language/expressions"> Literals</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="bool_literal.html" title="cpp/language/bool literal"> Boolean</a> - <a href="integer_literal.html" title="cpp/language/integer literal"> Integer</a> - <a href="floating_literal.html" title="cpp/language/floating literal"> Floating-point</a></td></tr>   
<tr class="t-nv"><td colspan="5"> <a href="character_literal.html" title="cpp/language/character literal"> Character</a> - <a href="string_literal.html" title="cpp/language/string literal"> String</a> - <a href="nullptr.html" title="cpp/language/nullptr"><tt>nullptr</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr> 
<tr class="t-nv"><td colspan="5"> <a href="user_literal.html" title="cpp/language/user literal"> User-defined</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Utilities</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="attributes.html" title="cpp/language/attributes"> Attributes</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Types</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="typedef.html" title="cpp/language/typedef"> <code>typedef</code> declaration</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="type_alias.html" title="cpp/language/type alias"> Type alias declaration</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Casts</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="implicit_cast.html" title="cpp/language/implicit conversion"> Implicit conversions</a> - <a href="explicit_cast.html" title="cpp/language/explicit cast"> Explicit conversions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="static_cast.html" title="cpp/language/static cast"><tt>static_cast</tt></a> - <a href="dynamic_cast.html" title="cpp/language/dynamic cast"><tt>dynamic_cast</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="const_cast.html" title="cpp/language/const cast"><tt>const_cast</tt></a> - <a href="reinterpret_cast.html" title="cpp/language/reinterpret cast"><tt>reinterpret_cast</tt></a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Memory allocation</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="new.html" title="cpp/language/new"> <code>new</code> expression</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="delete.html" title="cpp/language/delete"> <code>delete</code> expression</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> <a href="classes.html" title="cpp/language/classes"> Classes</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="class.html" title="cpp/language/class"> Class declaration</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="initializer_list.html" title="cpp/language/constructor"> Constructors</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="this.html" title="cpp/language/this"> <code>this</code> pointer</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="access.html" title="cpp/language/access"> Access specifiers</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="friend.html" title="cpp/language/friend"> <code>friend</code> specifier</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Class-specific function properties</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="virtual.html" title="cpp/language/virtual"> Virtual function</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="override.html" title="cpp/language/override"> <code>override</code> specifier</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="final.html" title="cpp/language/final"> <code>final</code> specifier</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="explicit.html" title="cpp/language/explicit"><tt>explicit</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="static.html" title="cpp/language/static"><tt>static</tt></a> </td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Special member functions</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="default_constructor.html" title="cpp/language/default constructor"> Default constructor</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="copy_constructor.html" title="cpp/language/copy constructor"> Copy constructor</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="move_constructor.html" title="cpp/language/move constructor"> Move constructor</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="as_operator.html" title="cpp/language/as operator" class="mw-redirect"> Copy assignment</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="move_operator.html" title="cpp/language/move operator" class="mw-redirect"> Move assignment</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="destructor.html" title="cpp/language/destructor"> Destructor</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"><a href="templates.html" title="cpp/language/templates"> Templates</a> </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="class_template.html" title="cpp/language/class template"> Class template </a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="function_template.html" title="cpp/language/function template"> Function template </a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="template_specialization.html" title="cpp/language/template specialization"> Template specialization</a></td></tr>   
<tr class="t-nv"><td colspan="5"> <a href="parameter_pack.html" title="cpp/language/parameter pack"> Parameter packs</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> Miscellaneous </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="asm.html" title="cpp/language/asm"> Inline assembly</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="history.html" title="cpp/language/history"> History of C++</a></td></tr>
</table></div></td></tr>
</table></div>
</div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="expressions.html" title="cpp/language/expressions"> Expressions</a><div class="t-navbar-menu"><div><div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> General </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="value_category.html" title="cpp/language/value category"> value categories</a> (lvalue, rvalue, xvalue)</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="eval_order.html" title="cpp/language/eval order"> order of evaluation</a> (sequence points)</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="constant_expression.html" title="cpp/language/constant expression"> constant expressions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="expressions.html#Unevaluated_expressions" title="cpp/language/expressions"> unevaluated expressions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="expressions.html#Primary_expressions" title="cpp/language/expressions"> primary expressions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="lambda.html" title="cpp/language/lambda">lambda-expression</a><span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Literals </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="integer_literal.html" title="cpp/language/integer literal">integer literals</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="floating_literal.html" title="cpp/language/floating literal">floating-point literals</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="bool_literal.html" title="cpp/language/bool literal">boolean literals</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="character_literal.html" title="cpp/language/character literal">character literals</a> including <a href="escape.html" title="cpp/language/escape">escape sequences</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="string_literal.html" title="cpp/language/string literal">string literals</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="nullptr.html" title="cpp/language/nullptr">null pointer literal</a><span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="user_literal.html" title="cpp/language/user literal">user-defined literal</a><span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Operators </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_assignment.html" title="cpp/language/operator assignment"> Assignment operators</a>: 
<code>a=b</code>, <code>a+=b</code>, <code>a-=b</code>, <code>a*=b</code>, <code>a/=b</code>, <code>a%=b</code>, <code>a&amp;=b</code>, <code>a|=b</code>, <code>a^=b</code>, <code>a&lt;&lt;=b</code>, <code>a&gt;&gt;=b</code></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_incdec.html" title="cpp/language/operator incdec"> Increment and decrement</a>: <code>++a</code>, <code>--a</code>, <code>a++</code>, <code>a--</code></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_arithmetic.html" title="cpp/language/operator arithmetic"> Arithmetic operators</a>:
<code>+a</code>, <code>-a</code>, <code>a+b</code>, <code>a-b</code>, <code>a*b</code>, <code>a/b</code>, <code>a%b</code>, <code>~a</code>, <code>a&amp;b</code>, <code>a|b</code>, <code>a^b</code>, <code>a&lt;&lt;b</code>, <code>a&gt;&gt;b</code> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_logical.html" title="cpp/language/operator logical"> Logical operators</a>: <code>a||b</code>, <code>a&amp;&amp;b</code>, <code>!a</code></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_comparison.html" title="cpp/language/operator comparison"> Comparison operators</a>: <code>a==b</code>, <code>a!=b</code>, <code>a&lt;b</code>, <code>a&gt;b</code>, <code>a&lt;=b</code>, <code>a&gt;=b</code>, <code>a&lt;=&gt;b</code><span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_member_access.html" title="cpp/language/operator member access"> Member access operators</a>: <code>a[b]</code>, <code>*a</code>, <code>&amp;a</code>, <code>a-&gt;b</code>, <code>a.b</code>, <code>a-&gt;*b</code>, <code>a.*b</code></td></tr>
<tr class="t-nv"><td colspan="5"> <strong class="selflink"> Other operators</strong>: <code>a(...)</code>, <code>a,b</code>, <code>a?b:c</code> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="new.html" title="cpp/language/new">new-expression</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="delete.html" title="cpp/language/delete">delete-expression</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="throw.html" title="cpp/language/throw">throw-expression</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="alignof.html" title="cpp/language/alignof"><code>alignof</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="sizeof.html" title="cpp/language/sizeof"><code>sizeof</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="sizeof....html" title="cpp/language/sizeof..."><code>sizeof...</code></a><span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="typeid.html" title="cpp/language/typeid"><code>typeid</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="noexcept.html" title="cpp/language/noexcept"><code>noexcept</code></a><span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="fold.html" title="cpp/language/fold">Fold expression</a><span class="t-mark-rev t-since-cxx17">(C++17)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_alternative.html" title="cpp/language/operator alternative">Alternative representations of operators</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operator_precedence.html" title="cpp/language/operator precedence">Precedence and associativity</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="operators.html" title="cpp/language/operators">Operator overloading</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="default_comparisons.html" title="cpp/language/default comparisons">Default comparisons</a><span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> Conversions </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="implicit_cast.html" title="cpp/language/implicit conversion">Implicit conversions</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="const_cast.html" title="cpp/language/const cast"><code>const_cast</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="static_cast.html" title="cpp/language/static cast"><code>static_cast</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="reinterpret_cast.html" title="cpp/language/reinterpret cast"><code>reinterpret_cast</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="dynamic_cast.html" title="cpp/language/dynamic cast"><code>dynamic_cast</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="explicit_cast.html" title="cpp/language/explicit cast">Explicit conversions</a> <code>(T)a</code>, <code>T(a)</code></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="cast_operator.html" title="cpp/language/cast operator">User-defined conversion</a></td></tr>
</table></div>
</div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="wikitable" style="font-size:85%;">

<tr>
<th rowspan="2"> Operator<br>name
</th>
<th rowspan="2" style="width: 9%"> Syntax
</th>
<th rowspan="2"> <a href="operators.html" title="cpp/language/operators">Over​load​able</a>
</th>
<th colspan="2"> Prototype examples (for <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">class</span> T</span></span>)
</th></tr>
<tr>
<th> Inside class definition
</th>
<th> Outside class definition
</th></tr>
<tr>
<td> function call
</td>
<td> <code>a(a1, a2)</code>
</td>
<td style="background: #90ff90; color: black; vertical-align: middle; text-align: center;" class="table-yes">Yes
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">R T<span class="sy4">::</span><span class="me2">operator</span><span class="br0">(</span><span class="br0">)</span><span class="br0">(</span>Arg1 <span class="sy3">&amp;</span>a1, Arg2 <span class="sy3">&amp;</span>a2, ...<span class="br0">)</span><span class="sy4">;</span></span></span>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td></tr>
<tr>
<td> comma
</td>
<td> <code>a, b</code>
</td>
<td style="background: #90ff90; color: black; vertical-align: middle; text-align: center;" class="table-yes">Yes
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">T2<span class="sy3">&amp;</span> T<span class="sy4">::</span><span class="me2">operator</span>,<span class="br0">(</span>T2 <span class="sy3">&amp;</span>b<span class="br0">)</span><span class="sy4">;</span></span></span>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">T2<span class="sy3">&amp;</span> operator,<span class="br0">(</span><span class="kw4">const</span> T <span class="sy3">&amp;</span>a, T2 <span class="sy3">&amp;</span>b<span class="br0">)</span><span class="sy4">;</span></span></span>
</td></tr>
<tr>
<td> conditional operator
</td>
<td> <code>a ? b : c</code>
</td>
<td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no"> No
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td>
<td style="background: #ececec; color: grey; vertical-align: middle; text-align: center;" class="table-na"> <small>N/A</small>
</td></tr></table>
<h3><span class="mw-headline" id="Explanation">Explanation</span></h3>
<p>The <i>function call</i> operator provides function semantics for any object.
</p><p>The <i>conditional operator</i> (colloquially referred to as <i>ternary conditional</i>) checks the boolean value of the first expression and,  depending on the resulting value, evaluates and returns either the second or the third expression.
</p>
<h4><span class="mw-headline" id="Built-in_function_call_operator">Built-in function call operator</span></h4>
<p>The function call expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td class="t-sdsc-nopad"> <span class="t-spar">E</span> <code><b>(</b></code> <span class="t-spar">A1</span><code><b>,</b></code> <span class="t-spar">A2</span><code><b>,</b></code> <span class="t-spar">A3</span><code><b>,</b></code>...<code><b>)</b></code>
</td>
<td class="t-sdsc-nopad">
</td>
<td class="t-sdsc-nopad">
</td></tr>

 

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr></table>
<p>where
</p>
<ul><li> <span class="t-spar">E</span> is an expression that names a <a href="functions.html" title="cpp/language/functions">function</a>
</li><li> <span class="t-spar">A1</span><code><b>,</b></code> <span class="t-spar">A2</span><code><b>,</b></code> <span class="t-spar">A3</span><code><b>,</b></code>... is a possibly empty list of arbitrary expressions<span class="t-rev-inl t-since-cxx11"><span> or braced-init-lists</span> <span><span class="t-mark-rev t-since-cxx11">(since C++11)</span></span></span>, except the comma operator is not allowed at the top level to avoid ambiguity.
</li></ul>
<p>The expression that names the function can be
</p>
<div class="t-li1"><span class="t-li">a)</span> lvalue expression that refers to a function</div>
<div class="t-li1"><span class="t-li">b)</span> pointer to function</div>
<div class="t-li1"><span class="t-li">c)</span> explicit <a href="operator_member_access.html" title="cpp/language/operator member access">class member access</a> expression that selects a member function</div>
<div class="t-li1"><span class="t-li">d)</span> implicit class member access expression, e.g. member function name used within another member function.</div>
<p>The function (or member) name specified by <code>E</code> can be overloaded, <a href="overload_resolution.html" title="cpp/language/overload resolution">overload resolution</a> rules used to decide which overload is to be called.
</p><p>If <code>E</code> specifies a member function, it may be virtual, in which case the final overrider of that function will be called, using dynamic dispatch at runtime.
</p><p>To call the function, 
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-until-cxx17"><td>
<p>The expression <code>E</code> as well as all expressions <code>A1</code>, <code>A2</code>, <code>A3</code>, etc, provided as arguments are evaluated in arbitrary order, <a href="eval_order.html" title="cpp/language/eval order">unsequenced</a> with respect to each other.
</p>
</td>
<td><span class="t-mark-rev t-until-cxx17">(until C++17)</span></td></tr>
<tr class="t-rev t-since-cxx17"><td>
<p>The expression <code>E</code> is sequenced before each of the expressions <code>A1</code>, <code>A2</code>, <code>A3</code> as well as default arguments, if any. The argument expressions are evaluated in arbitrary order, <a href="eval_order.html" title="cpp/language/eval order">indeterminately sequenced</a> with respect to each other.
</p>
</td>
<td><span class="t-mark-rev t-since-cxx17">(since C++17)</span></td></tr>
</table>
<p>Each function parameter is initialized with its corresponding argument after <a href="implicit_cast.html" title="cpp/language/implicit conversion">implicit conversion</a> if necessary. If there is no corresponding argument, the corresponding <a href="default_arguments.html" title="cpp/language/default arguments">default argument</a> is used, and if there is none, the program is ill-formed. If the call is made to a member function, then the <span class="t-c"><span class="mw-geshi cpp source-cpp">this</span></span> pointer to current object is converted as if by explicit cast to the <span class="t-c"><span class="mw-geshi cpp source-cpp">this</span></span> pointer expected by the function. The initialization and destruction of each parameter occurs in the context of the caller, which means, for example, that if constructor of a parameter throws an exception, the exception handlers defined within the function, even as a function-try block, are not considered. If the function is a variadic function, <a href="variadic_arguments.html#Default_conversions" title="cpp/language/variadic arguments">default argument promotions</a> are applied to all arguments matched by the ellipsis parameter. It is implementation-defined whether the <a href="lifetime.html" title="cpp/language/lifetime">lifetime</a> of a parameter ends when the function in which it is defined returns or at the end of the enclosing full-expression.
</p><p>The return type of a function call expression is the return type of the chosen function, decided using static binding (ignoring the <code>virtual</code> keyword), even if the overriding function that's actually called returns a different type. This allows the overriding functions to return pointers or references to classes that are derived from the return type returned by the base function, i.e. C++ supports <a href="https://en.wikipedia.org/wiki/Covariant_return_type" class="extiw" title="enwiki:Covariant return type">covariant return types</a>. If <code>E</code> specifies a destructor, the return type is <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span>.
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx17"><td>
<p>When an object of class type <code>X</code> is passed to or returned from a function, if each copy constructor, move constructor, and destructor of <code>X</code> is either trivial or deleted, and <code>X</code> has at least one non-deleted copy or move constructor, implementations are permitted to create a temporary object to hold the function parameter or result object.
</p><p>The temporary object is constructed from the function argument or return value, respectively, and the function's parameter or return object is initialized as if by using the non-deleted trivial constructor to copy the temporary (even if that constructor is inaccessible or would not be selected by overload resolution to perform a copy or move of the object).
</p><p>This allows objects of small class types, such as <span class="t-lc"><a href="../numeric/complex.html" title="cpp/numeric/complex">std::complex</a></span> or <span class="t-lc">std::span</span>, to be passed to or returned from functions in registers.
</p>
</td>
<td><span class="t-mark-rev t-since-cxx17">(since C++17)</span></td></tr>
</table>
<p>The value category of a function call expression is lvalue if the function returns an lvalue reference or an rvalue reference to function, is an xvalue if the function returns an rvalue reference to object, and is a prvalue otherwise. If the function call expression is a prvalue of object type, it must have complete type except <span class="t-rev-inl t-since-cxx17"><span>when the prvalue is not materialized, such as</span> <span><span class="t-mark-rev t-since-cxx17">(since C++17)</span></span></span> when used as the operand of <a href="decltype.html" title="cpp/language/decltype"><code>decltype</code></a> (or as the right operand of a <a href="operator_other.html#Built-in_comma_operator">built-in comma operator</a> that is the operand of <code>decltype</code>).
</p><p>Function call expression is similar in syntax to value initialization <span class="t-c"><span class="mw-geshi cpp source-cpp">T<span class="br0">(</span><span class="br0">)</span></span></span>, to <a href="explicit_cast.html" title="cpp/language/explicit cast">function-style cast</a> expression <span class="t-c"><span class="mw-geshi cpp source-cpp">T<span class="br0">(</span>A1<span class="br0">)</span></span></span>, and to direct initialization of a temporary <span class="t-c"><span class="mw-geshi cpp source-cpp">T<span class="br0">(</span>A1, A2, A3, ...<span class="br0">)</span></span></span>, where <code>T</code> is the name of a type.
</p>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;cstdio&gt;</span>
 
<span class="kw1">struct</span> S
<span class="br0">{</span>
    <span class="kw4">int</span> f1<span class="br0">(</span><span class="kw4">double</span> d<span class="br0">)</span>
    <span class="br0">{</span>
        <span class="kw1">return</span> printf<span class="br0">(</span><span class="st0">"%f <span class="es1">\n</span>"</span>, d<span class="br0">)</span><span class="sy4">;</span> <span class="co1">// variable argument function call</span>
    <span class="br0">}</span>
 
    <span class="kw4">int</span> f2<span class="br0">(</span><span class="br0">)</span>
    <span class="br0">{</span>
        <span class="kw1">return</span> f1<span class="br0">(</span><span class="nu0">7</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// member function call, same as this-&gt;f1()</span>
                      <span class="co1">// integer argument converted to double</span>
    <span class="br0">}</span>
<span class="br0">}</span><span class="sy4">;</span>
 
<span class="kw4">void</span> f<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    puts<span class="br0">(</span><span class="st0">"function called"</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// function call</span>
<span class="br0">}</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    f<span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span>    <span class="co1">// function call</span>
    S s<span class="sy4">;</span>
    s.<span class="me1">f2</span><span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// member function call</span>
<span class="br0">}</span></pre></div></div>
<p>Output:
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">function called
7.000000</pre></div></div> 
</div>
<h4><span class="mw-headline" id="Built-in_comma_operator">Built-in comma operator</span></h4>
<p>The comma operator expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td class="t-sdsc-nopad"> <span class="t-spar">E1</span> <code><b>,</b></code> <span class="t-spar">E2</span>
</td>
<td class="t-sdsc-nopad">
</td>
<td class="t-sdsc-nopad">
</td></tr>

 

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr></table>
<p>In a comma expression <span class="t-c"><span class="mw-geshi cpp source-cpp">E1, E2</span></span>, the expression <code>E1</code> is evaluated, its result is <a href="expressions.html#Discarded-value_expressions" title="cpp/language/expressions">discarded</a> (although if it has class type, it won't be destroyed <a href="lifetime.html#Temporary_object_lifetime" title="cpp/language/lifetime">until the end of the containing full expression</a>), and its side effects are completed before evaluation of the expression <code>E2</code> begins <span class="t-rev-inl t-until-cxx17"><span>(note that a user-defined <code>operator,</code> cannot guarantee sequencing)</span> <span><span class="t-mark-rev t-until-cxx17">(until C++17)</span></span></span>. 
</p><p>The type, value, and value category of the result of the comma expression are exactly the type, value, and value category of the second operand, <code>E2</code>. If <code>E2</code> is a temporary <span class="t-rev-inl t-since-cxx17"><span>expression</span> <span><span class="t-mark-rev t-since-cxx17">(since C++17)</span></span></span>, the result of the expression is that temporary <span class="t-rev-inl t-since-cxx17"><span>expression</span> <span><span class="t-mark-rev t-since-cxx17">(since C++17)</span></span></span>. If <code>E2</code> is a bit-field, the result is a bit-field.
</p><p>The comma in various comma-separated lists, such as function argument lists (<span class="t-c"><span class="mw-geshi cpp source-cpp">f<span class="br0">(</span>a, b, c<span class="br0">)</span></span></span>) and initializer lists <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">int</span> a<span class="br0">[</span><span class="br0">]</span> <span class="sy1">=</span> <span class="br0">{</span><span class="nu0">1</span>, <span class="nu0">2</span>, <span class="nu0">3</span><span class="br0">}</span></span></span>, is not the comma operator. If the comma operator needs to be used in such contexts, it has to be parenthesized: <span class="t-c"><span class="mw-geshi cpp source-cpp">f<span class="br0">(</span>a, <span class="br0">(</span>n<span class="sy2">++</span>, n <span class="sy2">+</span> b<span class="br0">)</span>, c<span class="br0">)</span></span></span>
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20 t-until-cxx23"><td>
<p>Using an unparenthesized comma expression as second (right) argument of a <a href="operator_member_access.html#Built-in_subscript_operator" title="cpp/language/operator member access">subscript operator</a> is deprecated.
</p><p>For example, <span class="t-c"><span class="mw-geshi cpp source-cpp">a<span class="br0">[</span>b, c<span class="br0">]</span></span></span> is deprecated and <span class="t-c"><span class="mw-geshi cpp source-cpp">a<span class="br0">[</span><span class="br0">(</span>b, c<span class="br0">)</span><span class="br0">]</span></span></span> is not.
</p>
</td>
<td><span class="t-mark-rev t-since-cxx20">(since C++20)</span><br><span class="t-mark-rev t-until-cxx23">(until C++23)</span></td></tr>
<tr class="t-rev t-since-cxx23"><td>
<p>An unparenthesized comma expression cannot be second (right) argument of a <a href="operator_member_access.html#Built-in_subscript_operator" title="cpp/language/operator member access">subscript operator</a>. For example, <span class="t-c"><span class="mw-geshi cpp source-cpp">a<span class="br0">[</span>b, c<span class="br0">]</span></span></span> is either ill-formed or equivalent to <span class="t-c"><span class="mw-geshi cpp source-cpp">a.<span class="me1">operator</span><span class="br0">[</span><span class="br0">]</span><span class="br0">(</span>b, c<span class="br0">)</span></span></span>.
</p><p>Parentheses are needed to for using a comma expression as the subscript, e.g., <span class="t-c"><span class="mw-geshi cpp source-cpp">a<span class="br0">[</span><span class="br0">(</span>b, c<span class="br0">)</span><span class="br0">]</span></span></span>.
</p>
</td>
<td><span class="t-mark-rev t-since-cxx23">(since C++23)</span></td></tr>
</table>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;iostream&gt;</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    <span class="kw4">int</span> n <span class="sy1">=</span> <span class="nu0">1</span><span class="sy4">;</span>
    <span class="kw4">int</span> m <span class="sy1">=</span> <span class="br0">(</span><span class="sy2">++</span>n, <a href="../io/cout.html"><span class="kw1762">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"n = "</span> <span class="sy1">&lt;&lt;</span> n <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span>, <span class="sy2">++</span>n, <span class="nu0">2</span> <span class="sy2">*</span> n<span class="br0">)</span><span class="sy4">;</span>
    <a href="../io/cout.html"><span class="kw1762">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"m = "</span> <span class="sy1">&lt;&lt;</span> <span class="br0">(</span><span class="sy2">++</span>m, m<span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>Output:
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">n = 2
m = 7</pre></div></div> 
</div>
<h4><span class="mw-headline" id="Conditional_operator">Conditional operator</span></h4>
<p>The conditional operator expressions have the form 
</p>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td class="t-sdsc-nopad"> <span class="t-spar">E1</span> <code><b>?</b></code> <span class="t-spar">E2</span> <code><b>:</b></code> <span class="t-spar">E3</span>
</td>
<td class="t-sdsc-nopad">
</td>
<td class="t-sdsc-nopad">
</td></tr>

 

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr></table>
<p>The first operand of the conditional operator is evaluated and <a href="implicit_cast.html" title="cpp/language/implicit conversion">contextually converted</a> to <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">bool</span></span></span>. After both the value evaluation and all side effects of the first operand are completed, if the result was <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">true</span></span></span>, the second operand is evaluated. If the result was <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw2">false</span></span></span>, the third operand is evaluated.
</p><p>The type and value category of the conditional expression <span class="t-c"><span class="mw-geshi cpp source-cpp">E1 <span class="sy4">?</span> E2 <span class="sy4">:</span> E3</span></span> are determined according to the following rules:
</p>
<div class="t-li1"><span class="t-li">1)</span> If either <code>E2</code> or <code>E3</code> has type <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span>, then one of the following must be true, or the program is ill-formed:</div>
<div class="t-li2"><span class="t-li">1.1)</span> Either <code>E2</code> or <code>E3</code> (but not both) is a (possibly parenthesized) <a href="throw.html" title="cpp/language/throw">throw-expression</a>. The result of the conditional operator has the type and the value category of the other expression. If the other expression is a <a href="bitfield.html" title="cpp/language/bit field">bit-field</a>, the result is a bit-field. Such conditional operator was commonly used in C++11 <a href="constexpr.html" title="cpp/language/constexpr">constexpr programming</a> prior to C++14.
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><a href="../string/basic_string.html"><span class="kw1233">std::<span class="me2">string</span></span></a> str <span class="sy1">=</span> <span class="nu0">2</span> <span class="sy2">+</span> <span class="nu0">2</span> <span class="sy1">==</span> <span class="nu0">4</span> <span class="sy4">?</span> <span class="st0">"OK"</span> <span class="sy4">:</span> <span class="kw1">throw</span> <a href="../error/logic_error.html"><span class="kw766">std::<span class="me2">logic_error</span></span></a><span class="br0">(</span><span class="st0">"2 + 2 != 4"</span><span class="br0">)</span><span class="sy4">;</span></pre></div></div></div>
<div class="t-li2"><span class="t-li">1.2)</span> Both <code>E2</code> and <code>E3</code> are of type <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span> (including the case when they are both throw-expressions). The result is a prvalue of type <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span>.
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="nu0">2</span> <span class="sy2">+</span> <span class="nu0">2</span> <span class="sy1">==</span> <span class="nu0">4</span> <span class="sy4">?</span> <span class="kw1">throw</span> <span class="nu0">123</span> <span class="sy4">:</span> <span class="kw1">throw</span> <span class="nu0">456</span><span class="sy4">;</span></pre></div></div></div>
<div class="t-li1"><span class="t-li">2)</span> Otherwise, if <code>E2</code> or <code>E3</code> are glvalue bit-fields of the same value category and of types cv1 T and cv2 T, respectively, the operands are considered to be of type cv T for the remainder of this section, where cv is the union of cv1 and cv2.</div>
<div class="t-li1"><span class="t-li">3)</span> Otherwise, if <code>E2</code> and <code>E3</code> have different types, at least one of which is a (possibly cv-qualified) class type, or both are glvalues of the same value category and have the same type except for cv-qualification, then an attempt is made to form an <a href="implicit_cast.html" title="cpp/language/implicit conversion">implicit conversion sequence</a> ignoring member access, whether an operand is a bit-field<span class="t-rev-inl t-since-cxx11"><span>, or whether a conversion function is deleted from each of the operands to the <i>target type</i> determined by the other operand</span> <span><span class="t-mark-rev t-since-cxx11">(since C++11)</span></span></span>, as described below. An operand (call it <code>X</code>) of type <code>TX</code> can be converted to the <i>target type</i> of the other operand (call it <code>Y</code>) of type <code>TY</code> as follows:</div>
<div class="t-li2"><span class="t-li">3.1)</span> If <code>Y</code> is an lvalue, the target type is <code>TY&amp;</code>, and the reference must bind directly to <span class="t-rev-inl t-until-cxx11"><span>an lvalue</span> <span><span class="t-mark-rev t-until-cxx11">(until C++11)</span></span></span><span class="t-rev-inl t-since-cxx11"><span>a glvalue</span> <span><span class="t-mark-rev t-since-cxx11">(since C++11)</span></span></span>;</div>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx11"><td>
<div class="t-li2"><span class="t-li">3.2)</span> If <code>Y</code> is an xvalue, the target type is <code>TY&amp;&amp;</code>, and the reference must bind directly;</div>
</td>
<td><span class="t-mark-rev t-since-cxx11">(since C++11)</span></td></tr>
</table>
<div class="t-li2"><span class="t-li">3.3)</span> If <code>Y</code> is <span class="t-rev-inl t-until-cxx11"><span>an rvalue</span> <span><span class="t-mark-rev t-until-cxx11">(until C++11)</span></span></span><span class="t-rev-inl t-since-cxx11"><span>a prvalue</span> <span><span class="t-mark-rev t-since-cxx11">(since C++11)</span></span></span>, or if neither the above conversion sequences can be formed and at least one of <code>TX</code> and <code>TY</code> is a (possibly cv-qualified) class type,</div>
<div class="t-li3"><span class="t-li">3.3.1)</span> if <code>TX</code> and <code>TY</code> are the same class type (ignoring cv-qualification) and <code>TY</code> is at least as cv-qualified as <code>TX</code>, the target type is <code>TY</code>,</div>
<div class="t-li3"><span class="t-li">3.3.2)</span> otherwise, if <code>TY</code> is a base class of <code>TX</code>, the target type is <code>TY</code> with the cv-qualifiers of <code>TX</code>:
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw1">struct</span> A <span class="br0">{</span><span class="br0">}</span><span class="sy4">;</span>
 
<span class="kw1">struct</span> B <span class="sy4">:</span> A <span class="br0">{</span><span class="br0">}</span><span class="sy4">;</span>
 
<span class="kw1">using</span> T <span class="sy1">=</span> <span class="kw4">const</span> B<span class="sy4">;</span>
 
A a <span class="sy1">=</span> <span class="kw2">true</span> <span class="sy4">?</span> A<span class="br0">(</span><span class="br0">)</span> <span class="sy4">:</span> T<span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// Y = A(), TY = A, X = T(), TX = const B, Target = const A</span></pre></div></div></div>
<div class="t-li3"><span class="t-li">3.3.3)</span> otherwise, the target type is the type that <code>Y</code> would have after applying the lvalue-to-rvalue, array-to-pointer, and function-to-pointer <a href="implicit_cast.html" title="cpp/language/implicit conversion">standard conversions</a></div>
<div class="t-li2"><span class="t-li">3.4)</span> If both sequences can be formed (<code>E2</code> to target type of <code>E3</code> and <code>E3</code> to target type of <code>E2</code>), or only one can be formed but it is the ambiguous conversion sequence, the program is ill-formed.</div>
<div class="t-li2"><span class="t-li">3.5)</span> If exactly one conversion sequence can be formed (note that it may still be ill-formed e.g. due to access violation), that conversion sequence is applied and the converted operand is used in place of the original operand for the remained of this description (starting at <span class="t-v">(4)</span>)</div>
<div class="t-li2"><span class="t-li">3.6)</span> If no conversion sequence can be formed, the operands are left unchanged for the remainder of this description</div>
<div class="t-li1"><span class="t-li">4)</span> If <code>E2</code> and <code>E3</code> are glvalues of the same type and the same value category, then the result has the same type and value category, and is a bit-field if at least one of <code>E2</code> and <code>E3</code> is a bit-field.</div>
<div class="t-li1"><span class="t-li">5)</span> Otherwise, the result is a prvalue. If <code>E2</code> and <code>E3</code> do not have the same type, and either has (possibly cv-qualified) class type, overload resolution is performed using the built-in candidates below to attempt to convert the operands to built-in types. If the overload resolution fails, the program is ill-formed. Otherwise, the selected conversions are applied and the converted operands are used in place of the original operands for step 6.</div>
<div class="t-li1"><span class="t-li">6)</span> The lvalue-to-rvalue, array-to-pointer, and function-to-pointer conversions are applied to the second and third operands. Then, </div>
<div class="t-li2"><span class="t-li">6.1)</span> If both <code>E2</code> and <code>E3</code> now have the same type, the result is a prvalue of that type <span class="t-rev-inl t-until-cxx17"><span>designating a temporary object</span> <span><span class="t-mark-rev t-until-cxx17">(until C++17)</span></span></span><span class="t-rev-inl t-since-cxx17"><span>whose result object is</span> <span><span class="t-mark-rev t-since-cxx17">(since C++17)</span></span></span> copy-initialized from whatever operand was selected after evaluating <code>E1</code>.</div>
<div class="t-li2"><span class="t-li">6.2)</span> If both <code>E2</code> and <code>E3</code> have arithmetic or enumeration type: the <a href="operator_arithmetic.html#conversions" title="cpp/language/operator arithmetic"><i>usual arithmetic conversions</i></a> are applied to bring them to <i>common type</i>, and that type is the result.</div>
<div class="t-li2"><span class="t-li">6.3)</span> If both <code>E2</code> and <code>E3</code> are pointers, or one is a pointer and the other is a null pointer constant, then pointer conversions and qualification conversions are applied to bring them to common type, and that type is the result.
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw4">int</span><span class="sy2">*</span> intPtr<span class="sy4">;</span>
 
<span class="kw1">using</span> Mixed <span class="sy1">=</span> decltype<span class="br0">(</span><span class="kw2">true</span> <span class="sy4">?</span> nullptr <span class="sy4">:</span> intPtr<span class="br0">)</span><span class="sy4">;</span>
 
static_assert<span class="br0">(</span><a href="../types/is_same.html"><span class="kw591">std::<span class="me2">is_same_v</span></span></a><span class="sy1">&lt;</span>Mixed, <span class="kw4">int</span><span class="sy2">*</span><span class="sy1">&gt;</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// nullptr becoming int*</span></pre></div></div></div>
<div class="t-li2"><span class="t-li">6.4)</span> If both <code>E2</code> and <code>E3</code> are pointers to members, or one is a pointer to member and the other is a null pointer constant, then pointer-to-member conversions and qualification conversions are applied to bring them to common type, and that type is the result.
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw1">struct</span> A
<span class="br0">{</span>
    <span class="kw4">int</span><span class="sy2">*</span> m_ptr<span class="sy4">;</span>
<span class="br0">}</span> a<span class="sy4">;</span>
 
<span class="kw4">int</span><span class="sy2">*</span> A<span class="sy4">::</span><span class="sy2">*</span> memPtr <span class="sy1">=</span> <span class="sy3">&amp;</span>A<span class="sy4">::</span><span class="me2">m_ptr</span><span class="sy4">;</span> <span class="co1">// memPtr is a pointer to member m_ptr of A</span>
 
<span class="co1">// memPtr makes nullptr as type of pointer to member m_ptr of A</span>
static_assert<span class="br0">(</span><a href="../types/is_same.html"><span class="kw591">std::<span class="me2">is_same_v</span></span></a><span class="sy1">&lt;</span>decltype<span class="br0">(</span><span class="kw2">false</span> <span class="sy4">?</span> memPtr <span class="sy4">:</span> nullptr<span class="br0">)</span>, <span class="kw4">int</span><span class="sy2">*</span>A<span class="sy4">::</span><span class="sy2">*</span><span class="sy1">&gt;</span><span class="br0">)</span><span class="sy4">;</span>
 
<span class="co1">// a.*memPtr is now just pointer to int and nullptr also becomes pointer to int</span>
static_assert<span class="br0">(</span><a href="../types/is_same.html"><span class="kw591">std::<span class="me2">is_same_v</span></span></a><span class="sy1">&lt;</span>decltype<span class="br0">(</span><span class="kw2">false</span> <span class="sy4">?</span> a.<span class="sy2">*</span>memPtr <span class="sy4">:</span> nullptr<span class="br0">)</span>, <span class="kw4">int</span><span class="sy2">*</span><span class="sy1">&gt;</span><span class="br0">)</span><span class="sy4">;</span></pre></div></div></div>
<div class="t-li2"><span class="t-li">6.5)</span> If both <code>E2</code> and <code>E3</code> are null pointer constants, and at least one of which is of type <span class="t-lc"><a href="../types/nullptr_t.html" title="cpp/types/nullptr t">std::nullptr_t</a></span>, then the result's type is <code>std::nullptr_t</code>.</div>
<div class="t-li2"><span class="t-li">6.6)</span> In all other cases, the program is ill-formed.</div>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr><td class="mbox-empty-cell"></td><td class="mbox-text" style="">This section is incomplete<br>Reason: any chance to make this more readable without losing the fine point? At the very least, a one-line micro-example for each bullet point would help tremendously </td></tr></table>
<p>For every pair of promoted arithmetic types <code>L</code> and <code>R</code> and for every type <code>P</code>, where <code>P</code> is a pointer, pointer-to-member, or scoped enumeration type, the following function signatures participate in the overload resolution performed in step 5 of the rules above:
</p>
<table class="t-dcl-begin"><tbody>
<tr class="t-dcl">
<td class="t-dcl-nopad"> <div><span class="mw-geshi cpp source-cpp">LR operator<span class="sy4">?:</span><span class="br0">(</span><span class="kw4">bool</span>, L, R<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl">
<td class="t-dcl-nopad"> <div><span class="mw-geshi cpp source-cpp">P operator<span class="sy4">?:</span><span class="br0">(</span><span class="kw4">bool</span>, P, P<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>where LR is the result of <a href="operator_arithmetic.html" title="cpp/language/operator arithmetic">usual arithmetic conversions</a> performed on <code>L</code> and <code>R</code>. The operator “<code>?:</code>” cannot be overloaded, these function signatures only exist for the purpose of overload resolution.
</p><p>The return type of a conditional operator is also accessible as the binary type trait <span class="t-lc"><a href="../types/common_type.html" title="cpp/types/common type">std::common_type</a></span>.
</p>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;string&gt;</span>
<span class="co2">#include &lt;iostream&gt;</span>
 
<span class="kw1">struct</span> Node
<span class="br0">{</span>
    Node<span class="sy2">*</span> next<span class="sy4">;</span>
    <span class="kw4">int</span> data<span class="sy4">;</span>
 
    <span class="co1">// deep-copying copy constructor</span>
    Node<span class="br0">(</span><span class="kw4">const</span> Node<span class="sy3">&amp;</span> other<span class="br0">)</span>
      <span class="sy4">:</span> next<span class="br0">(</span>other.<span class="me1">next</span> <span class="sy4">?</span> new Node<span class="br0">(</span><span class="sy2">*</span>other.<span class="me1">next</span><span class="br0">)</span> <span class="sy4">:</span> <a href="../types/NULL.html"><span class="kw109">NULL</span></a><span class="br0">)</span>
      , data<span class="br0">(</span>other.<span class="me1">data</span><span class="br0">)</span>
    <span class="br0">{</span><span class="br0">}</span>
 
    Node<span class="br0">(</span><span class="kw4">int</span> d<span class="br0">)</span> <span class="sy4">:</span> next<span class="br0">(</span><a href="../types/NULL.html"><span class="kw109">NULL</span></a><span class="br0">)</span>, data<span class="br0">(</span>d<span class="br0">)</span> <span class="br0">{</span><span class="br0">}</span>
 
    ~Node<span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span> delete next <span class="sy4">;</span> <span class="br0">}</span>
<span class="br0">}</span><span class="sy4">;</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>   
    <span class="co1">// simple rvalue example</span>
    <span class="kw4">int</span> n <span class="sy1">=</span> <span class="nu0">1</span> <span class="sy1">&gt;</span> <span class="nu0">2</span> <span class="sy4">?</span> <span class="nu0">10</span> <span class="sy4">:</span> <span class="nu0">11</span><span class="sy4">;</span>  <span class="co1">// 1 &gt; 2 is false, so n = 11</span>
 
    <span class="co1">// simple lvalue example</span>
    <span class="kw4">int</span> m <span class="sy1">=</span> <span class="nu0">10</span><span class="sy4">;</span> 
    <span class="br0">(</span>n <span class="sy1">==</span> m <span class="sy4">?</span> n <span class="sy4">:</span> m<span class="br0">)</span> <span class="sy1">=</span> <span class="nu0">7</span><span class="sy4">;</span> <span class="co1">// n == m is false, so m = 7</span>
 
    <span class="co1">//output the result</span>
    <a href="../io/cout.html"><span class="kw1762">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"n = "</span> <span class="sy1">&lt;&lt;</span> n <span class="sy1">&lt;&lt;</span> <span class="st0">"<span class="es1">\n</span>m = "</span> <span class="sy1">&lt;&lt;</span> m<span class="sy4">;</span>
<span class="br0">}</span></pre></div></div>
<p>Output:
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">n = 11
m = 7</pre></div></div> 
</div>
<h3><span class="mw-headline" id="Standard_library">Standard library</span></h3>
<p>Many classes in the standard library overload <code>operator()</code> to be used as function objects.
</p>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../memory/default_delete.html" title="cpp/memory/default delete"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   deletes the object or array  <br> <span class="t-mark">(public member function of <code>std::default_delete&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/plus.html" title="cpp/utility/functional/plus"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the sum of two arguments <br> <span class="t-mark">(public member function of <code>std::plus&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/minus.html" title="cpp/utility/functional/minus"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the difference between two arguments <br> <span class="t-mark">(public member function of <code>std::minus&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/multiplies.html" title="cpp/utility/functional/multiplies"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the product of two arguments <br> <span class="t-mark">(public member function of <code>std::multiplies&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/divides.html" title="cpp/utility/functional/divides"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the result of the division of the first argument by the second argument  <br> <span class="t-mark">(public member function of <code>std::divides&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/modulus.html" title="cpp/utility/functional/modulus"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the remainder from the division of the first argument by the second argument  <br> <span class="t-mark">(public member function of <code>std::modulus&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/negate.html" title="cpp/utility/functional/negate"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the negation of the argument <br> <span class="t-mark">(public member function of <code>std::negate&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/equal_to.html" title="cpp/utility/functional/equal to"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   checks if the arguments are equal <br> <span class="t-mark">(public member function of <code>std::equal_to&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/not_equal_to.html" title="cpp/utility/functional/not equal to"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   checks if the arguments are not equal <br> <span class="t-mark">(public member function of <code>std::not_equal_to&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/greater.html" title="cpp/utility/functional/greater"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   checks if the first argument is greater than the second <br> <span class="t-mark">(public member function of <code>std::greater&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/less.html" title="cpp/utility/functional/less"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   checks if the first argument is less than the second <br> <span class="t-mark">(public member function of <code>std::less&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/greater_equal.html" title="cpp/utility/functional/greater equal"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   checks if the first argument is greater than or equal to the second <br> <span class="t-mark">(public member function of <code>std::greater_equal&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/less_equal.html" title="cpp/utility/functional/less equal"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   checks if the first argument is less than or equal to the second <br> <span class="t-mark">(public member function of <code>std::less_equal&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/logical_and.html" title="cpp/utility/functional/logical and"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the logical AND of the two arguments <br> <span class="t-mark">(public member function of <code>std::logical_and&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/logical_or.html" title="cpp/utility/functional/logical or"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the logical OR of the two arguments <br> <span class="t-mark">(public member function of <code>std::logical_or&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/logical_not.html" title="cpp/utility/functional/logical not"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the logical NOT of the argument <br> <span class="t-mark">(public member function of <code>std::logical_not&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/bit_and.html" title="cpp/utility/functional/bit and"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the result of bitwise AND of two arguments <br> <span class="t-mark">(public member function of <code>std::bit_and&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/bit_or.html" title="cpp/utility/functional/bit or"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the result of bitwise OR of two arguments <br> <span class="t-mark">(public member function of <code>std::bit_or&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/bit_xor.html" title="cpp/utility/functional/bit xor"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the result of bitwise XOR of two arguments <br> <span class="t-mark">(public member function of <code>std::bit_xor&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/unary_negate.html" title="cpp/utility/functional/unary negate"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the logical complement of the result of a call to the stored predicate <br> <span class="t-mark">(public member function of <code>std::unary_negate&lt;Predicate&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/binary_negate.html" title="cpp/utility/functional/binary negate"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   returns the logical complement of the result of a call to the stored predicate <br> <span class="t-mark">(public member function of <code>std::binary_negate&lt;Predicate&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/reference_wrapper/operator%28%29.html" title="cpp/utility/functional/reference wrapper/operator()"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   calls the stored function  <br> <span class="t-mark">(public member function of <code>std::reference_wrapper&lt;T&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../utility/functional/function/operator%28%29.html" title="cpp/utility/functional/function/operator()"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   invokes the target <br> <span class="t-mark">(public member function of <code>std::function&lt;R(Args...)&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../locale/locale/operator%28%29.html" title="cpp/locale/locale/operator()"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   lexicographically compares two strings using this locale's collate facet <br> <span class="t-mark">(public member function of <code>std::locale</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../container/map/value_compare.html" title="cpp/container/map/value compare"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   compares two values of type <code>value_type</code> <br> <span class="t-mark">(public member function of <code>std::map&lt;Key,T,Compare,Allocator&gt;::value_compare</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../container/multimap/value_compare.html" title="cpp/container/multimap/value compare"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   compares two values of type <code>value_type</code> <br> <span class="t-mark">(public member function of <code>std::multimap&lt;Key,T,Compare,Allocator&gt;::value_compare</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../thread/packaged_task/operator%28%29.html" title="cpp/thread/packaged task/operator()"> <span class="t-lines"><span>operator()</span></span></a></div></div>
</td>
<td>   executes the function <br> <span class="t-mark">(public member function of <code>std::packaged_task&lt;R(Args...)&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../numeric/random/linear_congruential_engine/operator%28%29.html" title="cpp/numeric/random/linear congruential engine/operator()"> <span class="t-lines"><span>operator()</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>   advances the engine's state and returns the generated value <br> <span class="t-mark">(public member function of <code>std::linear_congruential_engine&lt;UIntType,a,c,m&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="../numeric/random/uniform_int_distribution/operator%28%29.html" title="cpp/numeric/random/uniform int distribution/operator()"> <span class="t-lines"><span>operator()</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>   generates the next random number in the distribution  <br> <span class="t-mark">(public member function of <code>std::uniform_int_distribution&lt;IntType&gt;</code>)</span> </td></tr>
</table>
<p>The comma operator is not overloaded by any class in the standard library. The boost library uses <span class="t-c"><span class="mw-geshi cpp source-cpp">operator,</span></span> in <a rel="nofollow" class="external text" href="https://www.boost.org/doc/libs/release/libs/assign/doc/index.html#intro">boost.assign</a>, <a rel="nofollow" class="external text" href="https://www.boost.org/doc/libs/release/libs/spirit/doc/html/index.html">boost.spirit</a>, and other libraries. The database access library <a rel="nofollow" class="external text" href="http://soci.sourceforge.net/doc.html">SOCI</a> also overloads <span class="t-c"><span class="mw-geshi cpp source-cpp">operator,</span></span>.
</p>
<h3><span class="mw-headline" id="Defect_reports">Defect reports</span></h3>
<p>The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
</p>
<table class="dsctable" style="font-size:0.8em">
<tr>
<th> DR
</th>
<th> Applied to
</th>
<th> Behavior as published
</th>
<th> Correct behavior
</th></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/446.html">CWG 446</a>
</td>
<td> C++98
</td>
<td> it was unspecified whether a temporary is created for an<br>lvalue-to-rvalue conversion on the conditional operator
</td>
<td> always creates a temporary if<br>the operator returns a class rvalue
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/462.html">CWG 462</a>
</td>
<td> C++98
</td>
<td> if the second operand of a comma operator is a temporary,<br>it was unspecified whether its lifetime will be extended when<br>the result of the comma expression is bound to a reference
</td>
<td> the result of the comma expression<br>is the temporary in this case<br>(hence its lifetime is extended)
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/587.html">CWG 587</a>
</td>
<td> C++98
</td>
<td> when the second and third operands of a conditional<br>operator are lvalues of the same type except for<br>cv-qualification, the result was an lvalue if these<br>operands have class types or an rvalue otherwise
</td>
<td> the result is always<br>an lvalue in this case
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/1029.html">CWG 1029</a>
</td>
<td> C++98
</td>
<td> the type of a destructor call was unspecified
</td>
<td> specified as <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span></span></span>
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/1550.html">CWG 1550</a>
</td>
<td> C++98
</td>
<td> parenthesized throw-expression were not allowed in<br>conditional expressions if other operand is non-void
</td>
<td> accepted
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/1560.html">CWG 1560</a>
</td>
<td> C++98
</td>
<td> void operand of conditional operators caused<br>gratuitous lvalue-to-rvalue conversion on the<br>other operand, always resulting in rvalue
</td>
<td> a conditional expression<br>with a void can be lvalue
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/1805.html">CWG 1805</a>
</td>
<td> C++98
</td>
<td> in case 3.3.3) of conditional expressions, array-to-pointer<br>and function-to-pointer conversions were not applied
</td>
<td> apply these conversions
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/1895.html">CWG 1895</a>
</td>
<td> C++98<br>C++11
</td>
<td> unclear if deleted (C++11) or inaccessible (C++98)<br>conversion function prevents conversion in<br>conditional expressions, and conversions from base<br>class to derived class prvalue were not considered
</td>
<td> handled like<br>overload resolution
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/1932.html">CWG 1932</a>
</td>
<td> C++98
</td>
<td> same-type bit-fields were missing in conditional expressions
</td>
<td> handled by underlying types
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/2226.html">CWG 2226</a>
</td>
<td> C++11
</td>
<td> when determining the target type of the other<br>operand of a conditional operator, reference could<br>not bind to an xvalue if that operand is an lvalue
</td>
<td> allowed
</td></tr>
<tr>
<td> <a rel="nofollow" class="external text" href="https://cplusplus.github.io/CWG/issues/2321.html">CWG 2321</a>
</td>
<td> C++98
</td>
<td> when determining the target type of the other operand<br>of a conditional operator, a derived class type could<br>not be converted to a less cv-qualified base class type
</td>
<td> allowed to convert to the base<br>class type with the cv-qualification<br>from the derived class operand
</td></tr></table>
<h3><span class="mw-headline" id="See_also">See also</span></h3>
<p><a href="operator_precedence.html" title="cpp/language/operator precedence">Operator precedence</a>
<a href="operators.html" title="cpp/language/operators">Operator overloading</a>
</p>
<table class="wikitable">

<tr style="text-align:center">
<th colspan="7"> Common operators
</th></tr>
<tr style="text-align:center">
<td> <a href="operator_assignment.html" title="cpp/language/operator assignment"> assignment</a>
</td>
<td> <a href="operator_incdec.html" title="cpp/language/operator incdec"> increment<br>decrement</a>
</td>
<td> <a href="operator_arithmetic.html" title="cpp/language/operator arithmetic"> arithmetic</a>
</td>
<td> <a href="operator_logical.html" title="cpp/language/operator logical"> logical</a>
</td>
<td> <a href="operator_comparison.html" title="cpp/language/operator comparison"> comparison</a>
</td>
<td> <a href="operator_member_access.html" title="cpp/language/operator member access"> member<br>access</a>
</td>
<td> <strong class="selflink"> other</strong>
</td></tr>
<tr style="text-align:center">
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp">a <span class="sy1">=</span> b<br>
a <span class="sy2">+</span><span class="sy1">=</span> b<br>
a <span class="sy2">-</span><span class="sy1">=</span> b<br>
a <span class="sy2">*</span><span class="sy1">=</span> b<br>
a <span class="sy2">/</span><span class="sy1">=</span> b<br>
a <span class="sy2">%</span><span class="sy1">=</span> b<br>
a <span class="sy3">&amp;</span><span class="sy1">=</span> b<br>
a <span class="sy3">|</span><span class="sy1">=</span> b<br>
a <span class="sy3">^</span><span class="sy1">=</span> b<br>
a <span class="sy1">&lt;&lt;=</span> b<br>
a <span class="sy1">&gt;&gt;=</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">++</span>a<br>
<span class="sy2">--</span>a<br>
a<span class="sy2">++</span><br>
a<span class="sy2">--</span></span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">+</span>a<br>
<span class="sy2">-</span>a<br>
a <span class="sy2">+</span> b<br>
a <span class="sy2">-</span> b<br>
a <span class="sy2">*</span> b<br>
a <span class="sy2">/</span> b<br>
a <span class="sy2">%</span> b<br>
~a<br>
a <span class="sy3">&amp;</span> b<br>
a <span class="sy3">|</span> b<br>
a <span class="sy3">^</span> b<br>
a <span class="sy1">&lt;&lt;</span> b<br>
a <span class="sy1">&gt;&gt;</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy3">!</span>a<br>
a <span class="sy3">&amp;&amp;</span> b<br>
a <span class="sy3">||</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp">a <span class="sy1">==</span> b<br>
a <span class="sy3">!</span><span class="sy1">=</span> b<br>
a <span class="sy1">&lt;</span> b<br>
a <span class="sy1">&gt;</span> b<br>
a <span class="sy1">&lt;=</span> b<br>
a <span class="sy1">&gt;=</span> b<br>
a <span class="sy1">&lt;=&gt;</span> b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp">a<span class="br0">[</span>b<span class="br0">]</span><br>
<span class="sy2">*</span>a<br>
<span class="sy3">&amp;</span>a<br>
a<span class="sy2">-</span><span class="sy1">&gt;</span>b<br>
a.<span class="me1">b</span><br>
a<span class="sy2">-</span><span class="sy1">&gt;</span><span class="sy2">*</span>b<br>
a.<span class="sy2">*</span>b</span></span>
</p>
</td>
<td>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp">a<span class="br0">(</span>...<span class="br0">)</span><br>
a, b<br>
a <span class="sy4">?</span> b <span class="sy4">:</span> c</span></span>
</p>
</td></tr>
<tr>
<th colspan="7"> Special operators
</th></tr>
<tr>
<td colspan="7">
<p><a href="static_cast.html" title="cpp/language/static cast"><tt>static_cast</tt></a> converts one type to another related type <br>
<a href="dynamic_cast.html" title="cpp/language/dynamic cast"><tt>dynamic_cast</tt></a> converts within inheritance hierarchies <br>
<a href="const_cast.html" title="cpp/language/const cast"><tt>const_cast</tt></a> adds or removes <a href="cv.html" title="cpp/language/cv">cv</a> qualifiers<br>
<a href="reinterpret_cast.html" title="cpp/language/reinterpret cast"><tt>reinterpret_cast</tt></a> converts type to unrelated type<br>
<a href="explicit_cast.html" title="cpp/language/explicit cast">C-style cast</a> converts one type to another by a mix of <code>static_cast</code>, <code>const_cast</code>, and <code>reinterpret_cast</code> <br>
<a href="new.html" title="cpp/language/new"><tt>new</tt></a> creates objects with dynamic storage duration<br>
<a href="delete.html" title="cpp/language/delete"><tt>delete</tt></a> destructs objects previously created by the new expression and releases obtained memory area<br>
<a href="sizeof.html" title="cpp/language/sizeof"><tt>sizeof</tt></a> queries the size of a type<br>
<a href="sizeof....html" title="cpp/language/sizeof..."><tt>sizeof...</tt></a> queries the size of a <a href="parameter_pack.html" title="cpp/language/parameter pack">parameter pack</a> <span class="t-mark-rev t-since-cxx11">(since C++11)</span><br>
<a href="typeid.html" title="cpp/language/typeid"><tt>typeid</tt></a> queries the type information of a type<br>
<a href="noexcept.html" title="cpp/language/noexcept"><tt>noexcept</tt></a> checks if an expression can throw an exception <span class="t-mark-rev t-since-cxx11">(since C++11)</span><br>
<a href="alignof.html" title="cpp/language/alignof"><tt>alignof</tt></a> queries alignment requirements of a type <span class="t-mark-rev t-since-cxx11">(since C++11)</span>
</p>
</td></tr></table>
<table class="t-dsc-begin">

</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 12653/1000000
Preprocessor generated node count: 23555/1000000
Post‐expand include size: 341431/2097152 bytes
Template argument size: 72885/2097152 bytes
Highest expansion depth: 37/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:708-0!*!0!!en!*!* and timestamp 20220721100425 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    Retrieved from "<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/language/operator_other&amp;oldid=141217">https://en.cppreference.com/mwiki/index.php?title=cpp/language/operator_other&amp;oldid=141217</a>"                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>Navigation</h5>
            <ul><li><a href="https://en.cppreference.com/w/cpp/language/operator_other">Online version</a></li><li>Offline version retrieved 2022-07-30 14:05.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> This page was last modified on 21 July 2022, at 03:04.</li>
                                    <li id="footer-info-viewcount">This page has been accessed 243,358 times.</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.ColiruCompiler","ext.gadget.MathJax"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 0.045 secs. -->
	</body>
<!-- Cached 20220721100633 -->
</html>